package com.chd.ledger_server.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * 权限配置
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                //请求拦截
//                .antMatchers("/users/login").permitAll() // 放行登录接口
//                .anyRequest().authenticated()
                //开发环境中，开放所有请求
                .anyRequest().permitAll()
                .and()
                .csrf().disable(); // 如果是API服务，通常需要禁用CSRF
    }
}
